#!/bin/sh
#
# description: Regina Stack daemon.
# processname: rxstack

# 2014-06-09 R Narron  Rewrite for Slackware 

DAEMON=/usr/bin/rxstack
RETVAL=0

# start rxstack
rxstack_start() {
  if [ -x $DAEMON ]; then
    echo -n "Starting Regina Stack: $DAEMON"
    $DAEMON -d
    RETVAL=$?
  fi
}

# stop rxstack
rxstack_stop() {
  echo -n "Shutting down Regina Stack: "
  killall -2 $DAEMON
  RETVAL=$?
}

# restart rxstack
rxstack_restart() {
  rxstack_stop
  sleep 1
  rxstack_start
}

case "$1" in
  start)
    rxstack_start
    ;;
  stop)
    rxstack_stop
    ;;
  restart)
    rxstack_restart
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    RETVAL=1
esac

exit $RETVAL
